home *** CD-ROM | disk | FTP | other *** search
- package classes
- {
- import classes.game.Game;
- import flash.display.*;
- import flash.events.*;
- import flash.media.*;
- import libs.kjc.*;
-
- public class Main extends MovieClip
- {
-
- public static var howGame:Function;
-
- public static var reGame:Function;
-
- public static var startGame:Function;
-
- public static var setSoundFn:Function;
-
- public static var playSound:Function;
-
- public static var setStageFocus:Function;
-
-
- private var keyCd:String;
-
- private var mainMc:MovieClip;
-
- private var vol:Number;
-
- private var keyT:int;
-
- private var sndA:Array;
-
- private var playOn:Boolean;
-
- private var keyOn:Boolean;
-
- public function Main()
- {
- super();
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- stage.showDefaultContextMenu = false;
- startGame = gameStart;
- howGame = howtoStart;
- reGame = introStart;
- playSound = soundPlay;
- setSoundFn = setSound;
- setStageFocus = setFocusStage;
- sndA = new Array();
- sndA[0] = new BtnSnd();
- sndA[1] = new Success();
- sndA[2] = new CameraSnd();
- sndA[3] = new Pong();
- sndA[4] = new Turn();
- mainMc = new MovieClip();
- this.addChildAt(mainMc,0);
- playOn = false;
- keyOn = false;
- introStart();
- stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFn);
- stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFn);
- }
-
- private function keyAc(param1:Event) : void
- {
- if(playOn == false)
- {
- keyT = 0;
- keyOn = false;
- this.removeEventListener(Event.ENTER_FRAME,keyAc);
- return;
- }
- if(keyT % 3 == 0 || keyCd == "Z" || keyCd == "X" || keyCd == "C")
- {
- Game(mainMc.getChildAt(0)).keyFn(keyCd);
- }
- ++keyT;
- }
-
- public function soundPlay(param1:int) : void
- {
- if(vol == 0)
- {
- return;
- }
- if(param1 >= sndA.length)
- {
- return;
- }
- Sound(sndA[param1]).play();
- }
-
- public function setFocusStage() : void
- {
- stage.focus = this;
- }
-
- private function keyDownFn(param1:KeyboardEvent) : void
- {
- if(playOn == false)
- {
- return;
- }
- var _loc2_:int = int(param1.keyCode);
- switch(_loc2_)
- {
- case 37:
- keyCd = "LEFT";
- break;
- case 39:
- keyCd = "RIGHT";
- break;
- case 90:
- keyCd = "Z";
- break;
- case 88:
- keyCd = "X";
- break;
- case 67:
- keyCd = "C";
- break;
- default:
- return;
- }
- if(keyOn == false)
- {
- keyOn = true;
- this.addEventListener(Event.ENTER_FRAME,keyAc);
- }
- }
-
- private function keyUpFn(param1:KeyboardEvent) : void
- {
- var _loc2_:String = null;
- var _loc3_:int = int(param1.keyCode);
- switch(_loc3_)
- {
- case 37:
- _loc2_ = "LEFT";
- break;
- case 39:
- _loc2_ = "RIGHT";
- break;
- case 90:
- _loc2_ = "Z";
- break;
- case 88:
- _loc2_ = "X";
- break;
- case 67:
- _loc2_ = "C";
- break;
- default:
- return;
- }
- if(_loc2_ != keyCd)
- {
- return;
- }
- keyCd = "";
- }
-
- internal function setSound(param1:Number) : void
- {
- soundPlay(0);
- vol = param1;
- this.soundTransform = new SoundTransform(param1,0);
- }
-
- public function introStart() : void
- {
- playOn = false;
- SoundMixer.stopAll();
- KJC_general.RemoveAllChild(mainMc);
- var _loc1_:Intro = new Intro();
- mainMc.addChild(_loc1_);
- _loc1_.x = 250;
- _loc1_.y = 187.5;
- }
-
- public function gameStart() : void
- {
- SoundMixer.stopAll();
- soundPlay(0);
- KJC_general.RemoveAllChild(mainMc);
- var _loc1_:Game = new Game();
- mainMc.addChild(_loc1_);
- playOn = true;
- setFocusStage();
- }
-
- public function howtoStart() : void
- {
- playOn = false;
- SoundMixer.stopAll();
- soundPlay(0);
- KJC_general.RemoveAllChild(mainMc);
- var _loc1_:HowTo = new HowTo();
- mainMc.addChild(_loc1_);
- }
- }
- }
-